package com.demo.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 权限控制
 * @date 2021/4/30
 */
@RestController
@RequestMapping("/user")
@PreAuthorize("hasRole('ROLE_2')")
public class UserController {

    @RequestMapping("/add")
    public Object add(){
        return "添加用户";
    }

    @RequestMapping("/delete")
    public Object delete(){
        return "删除用户";
    }

    @RequestMapping("/loginErr")
    public Object login(){
        return "请登入";
    }

    @RequestMapping("/err")
    public Object err(){
        int i = 1 /0;
        return "err";
    }
}
